home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / M2Crypto / SSL / cb.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  2KB  |  75 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import sys
  5. import Context
  6. from M2Crypto import m2
  7.  
  8. def ssl_verify_callback_stub(ssl_ctx_ptr, x509_ptr, errnum, errdepth, ok):
  9.     return ok
  10.  
  11. unknown_issuer = [
  12.     m2.X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT,
  13.     m2.X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY,
  14.     m2.X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE,
  15.     m2.X509_V_ERR_CERT_UNTRUSTED]
  16.  
  17. def ssl_verify_callback(ssl_ctx_ptr, x509_ptr, errnum, errdepth, ok):
  18.     ssl_ctx = Context.map()[long(ssl_ctx_ptr)]
  19.     if errnum in unknown_issuer:
  20.         if ssl_ctx.get_allow_unknown_ca():
  21.             sys.stderr.write('policy: %s: permitted...\n' % m2.x509_get_verify_error(errnum))
  22.             sys.stderr.flush()
  23.             ok = 1
  24.         
  25.     
  26.     if ok:
  27.         if ssl_ctx.get_verify_depth() >= errdepth:
  28.             ok = 1
  29.         else:
  30.             ok = 0
  31.     
  32.     return ok
  33.  
  34.  
  35. def ssl_verify_callback_allow_unknown_ca(ok, store):
  36.     errnum = store.get_error()
  37.     if errnum in unknown_issuer:
  38.         ok = 1
  39.     
  40.     return ok
  41.  
  42.  
  43. def ssl_info_callback(where, ret, ssl_ptr):
  44.     w = where & ~(m2.SSL_ST_MASK)
  45.     if w & m2.SSL_ST_CONNECT:
  46.         state = 'SSL connect'
  47.     elif w & m2.SSL_ST_ACCEPT:
  48.         state = 'SSL accept'
  49.     else:
  50.         state = 'SSL state unknown'
  51.     if where & m2.SSL_CB_LOOP:
  52.         sys.stderr.write('LOOP: %s: %s\n' % (state, m2.ssl_get_state_v(ssl_ptr)))
  53.         sys.stderr.flush()
  54.         return None
  55.     
  56.     if where & m2.SSL_CB_EXIT:
  57.         if not ret:
  58.             sys.stderr.write('FAILED: %s: %s\n' % (state, m2.ssl_get_state_v(ssl_ptr)))
  59.             sys.stderr.flush()
  60.         else:
  61.             sys.stderr.write('INFO: %s: %s\n' % (state, m2.ssl_get_state_v(ssl_ptr)))
  62.             sys.stderr.flush()
  63.         return None
  64.     
  65.     if where & m2.SSL_CB_ALERT:
  66.         if where & m2.SSL_CB_READ:
  67.             w = 'read'
  68.         else:
  69.             w = 'write'
  70.         sys.stderr.write('ALERT: %s: %s: %s\n' % (w, m2.ssl_get_alert_type_v(ret), m2.ssl_get_alert_desc_v(ret)))
  71.         sys.stderr.flush()
  72.         return None
  73.     
  74.  
  75.